<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.milk.entity.Stock" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>库存管理</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            background: linear-gradient(90deg, #ff9a9e, #fad0c4);
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            background: #fff;
            border-radius: 10px;
            box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
            padding: 30px;
            width: 90%;
            max-width: 800px;
        }

        h2 {
            color: #333;
            text-align: center;
            margin-bottom: 20px;
        }

        .nav-links {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin-bottom: 20px;
        }

        .nav-links a {
            text-decoration: none;
            color: #fff;
            background-color: #ff4b2b;
            padding: 10px 20px;
            border-radius: 20px;
            font-size: 14px;
            font-weight: bold;
            text-transform: uppercase;
            transition: background-color 0.3s ease;
        }

        .nav-links a:hover {
            background-color: #ff3a1f;
        }

        form {
            background: #f9f9f9;
            padding: 20px;
            border-radius: 10px;
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            color: #333;
        }

        input[type="text"],
        input[type="number"] {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 14px;
        }

        button[type="submit"] {
            width: 100%;
            padding: 12px;
            background-color: #ff4b2b;
            color: #fff;
            border: none;
            border-radius: 20px;
            font-size: 14px;
            font-weight: bold;
            text-transform: uppercase;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        button[type="submit"]:hover {
            background-color: #ff3a1f;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            background-color: #fff;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        th, td {
            padding: 15px;
            text-align: center;
            border-bottom: 1px solid #ddd;
        }

        th {
            background-color: #ff4b2b;
            color: white;
            font-weight: bold;
        }

        tr:hover {
            background-color: #f9f9f9;
        }

        .no-data {
            text-align: center;
            color: #888;
            font-style: italic;
            padding: 20px;
        }

        @media (max-width: 600px) {
            .container {
                padding: 20px;
            }

            .nav-links {
                flex-direction: column;
                align-items: center;
            }

            .nav-links a {
                width: 100%;
                text-align: center;
            }

            th, td {
                padding: 10px;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <h2>库存管理</h2>
    <div class="nav-links">
        <a href="#">添加库存</a>
        <a href="<%=request.getContextPath()%>/stock/viewAll">查看所有库存</a>
        <a href="<%=request.getContextPath()%>/stock/lowAlert">查看库存预警</a>
    </div>
    <form action="<%=request.getContextPath()%>/stock/update" method="post">
<%--        <label for="drinkIdUpdate">饮品ID</label>--%>
<%--        <input type="text" id="drinkIdUpdate" name="drinkId" placeholder="请输入要更新库存数量的饮品ID">--%>
<%--        <label for="newQuantity">新库存数量</label>--%>
<%--        <input type="number" id="newQuantity" name="newQuantity" placeholder="请输入新的库存数量">--%>
        <button type="submit">更新</button>
    </form>
    <table>
        <tr>

            <th>饮品ID</th>
            <th>当前库存数量</th>
            <th>库存预警阈值</th>
        </tr>
        <%
            List<Stock> stocks = (List<Stock>) request.getAttribute("stocks");
            if (stocks != null && !stocks.isEmpty()) {
                for (Stock stock : stocks) {
        %>
        <tr>
            <td><%=stock.getDrinkId()%></td>
            <td><%=stock.getQuantity()%></td>
            <td><%=stock.getLowStockThreshold()%></td>
        </tr>
        <%
            }
        } else {
        %>
        <tr>
            <td colspan="3" class="no-data">没有库存数据</td>
        </tr>
        <%
            }
        %>
    </table>
</div>
</body>
</html>